<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | Data Tables</title>
    <script th:src="@{/adminLTE/js/jquery-3.4.1.min.js}"></script>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/adminLTE/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/adminLTE/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/adminLTE/dist/css/skins/_all-skins.min.css}">

    <script type="text/javascript">
            $(document).ready(function () {
                $("#districtId").change(function () {
                    $.get("/doors/getStreetByDistrictId?id=" + $("#districtId").val(), function (data) {
                        for (var i=0 ;i< data.length;i++){
                            $('#streetId option').remove();

                        }
                        console.log(data);
                        if (data!=null) {
                            for (var i=0 ; i<data.length;i++){
                                $('#streetId').append("<option>"+data[i].streetName+"</option>>");
                                //$(".box1").remove();
                            }
                            return false;
                        }
                    }, "json");
                });
            });
    </script>
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">

    <div th:replace="/common/header :: header"></div>

    <!-- Left side column. contains the logo and sidebar -->
    <div th:replace="/common/menu :: menu"></div>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>门牌区域统计分析</h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>统计分析</a></li>
                <li class="active">门牌区域统计分析</li>
            </ol>
        </section>
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <div class="box">
                        <div class="box-header">
                        </div>
                        <form role="form" th:action="@{/Statistics/search}" method="post" th:object="${door}">
                            <div class="box-body">
                                <div class="form-group" >
                                    <label for="districtId">选择行政区</label>
                                    <select data-placeholder="行政区"  id="districtId" name="districtId"  class="form-control"
                                                   data-rel="chosen">
                                        <option th:value="请选择："></option>
                                        <option th:each="District:${districtList}" th:value="${District.districtId}" th:text="${District.districtName}">
                                        </option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="streetId">街道</label>
                                    <select type="text" name="streetId" id="streetId" class="form-control" >
                                        <option th:value="请选择："></option>
                                    </select>
                                </div>
                            </div>
                            <!-- /.box-body -->
                            <h3>所属门牌信息</h3>
                            <div class="row" >
                                <div class="col-md-12">
                                    <table class="table table-hover" id="mytable1">
                                        <thead>
                                        <th>门牌名：</th>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!--/.box-->
                </div>
                <!--/.col-->
            </div>
            <!--/.row-->
        </section>
        <!--/.content-->
    </div>
    <!-- /.content-wrapper -->
    <div th:replace="/common/footer :: footer"></div>


</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script th:src="@{/adminLTE/bower_components/jquery/dist/jquery.min.js}"></script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/adminLTE/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
<!-- DataTables -->
<script th:src="@{/adminLTE/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/adminLTE/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/adminLTE/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/adminLTE/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/adminLTE/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/adminLTE/dist/js/demo.js}"></script>
<!--page script-->
<script>
    $('#streetId').blur(function () {
        var streetName = $(this).val();

        $.ajax({
            url:"/doors/streetDoorData?streetName="+streetName,
            type: "get",
            datatype:"josn",
            success:function (data) {
                $("tbody").children().remove();
                $.each(data,function (i,e) {
                    $("tbody").append($("<tr>").append($("<td>")  .text(e['doorName'])));
                })
            }
        })
    })
        //.addClass(box1)
    $(function () {
        $('#mytable1').DataTable({
            "language": {
                "lengthMenu": "每页 _MENU_ 条记录",
                // "zeroRecords": "没有找到记录",
                "info": "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )",
                // "infoEmpty": "无记录",
                "infoFiltered": "(从 _MAX_ 条记录过滤)",
                "search":"快速检索: ",
                "oPaginate": {
                    "sPrevious": "上页",
                    "sNext": "下页"
                }
            }
        })
        })
</script>

</body>
</html>
